package com.bruce.demo2.patterns.demo2.structural.demo07.adapter.demo2;

/**
 * @PROJECT_NAME: design_patterns
 * @DESCRIPTION: 计算机只支持使用CD读卡器
 * @AUTHOR: CNBruceLee
 * @DATE: 2021/7/22 21:36
 */
public class Computer {
    private SDCard sdCard;

    /**
     * 插入读卡器
     *
     * @param sdCard
     */
    public void setSdCard(SDCard sdCard) {
        this.sdCard = sdCard;
    }

    public String readSD() {
        if (this.sdCard == null) throw new NullPointerException("sd card null");
        return sdCard.readSD();
    }

    public void writeSD(String data) {
        if (this.sdCard == null) throw new NullPointerException("sd card null");
        sdCard.writeSD(data);
    }
}
